package com.lingyu.jsjx.service.impl;

import java.util.List;
import java.util.Map;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lingyu.jsjx.mapper.AwardRecordMapper;
import com.lingyu.jsjx.domain.AwardRecord;
import com.lingyu.jsjx.service.IAwardRecordService;

/**
 * 我的成就
 * Service业务层处理
 *
 * @author ruoyi
 * @date 2025-08-08
 */
@Service
public class AwardRecordServiceImpl extends ServiceImpl<AwardRecordMapper, AwardRecord> implements IAwardRecordService {
    @Autowired
    private AwardRecordMapper awardRecordMapper;

    /**
     * 查询我的成就
     *
     * @param awardId 我的成就
     *                主键
     * @return 我的成就
     */
    @Override
    public AwardRecord selectAwardRecordByAwardId(Long awardId) {
        return awardRecordMapper.selectAwardRecordByAwardId(awardId);
    }

    /**
     * 查询我的成就
     * 列表
     *
     * @param awardRecord 我的成就
     * @return 我的成就
     */
    @Override
    @DataScope(deptAlias = "u", userAlias = "ar",type = "jsjx")
    public List<AwardRecord> selectAwardRecordList(AwardRecord awardRecord) {
        return awardRecordMapper.selectAwardRecordList(awardRecord);
    }

    /**
     * 新增我的成就
     *
     * @param awardRecord 我的成就
     * @return 结果
     */
    @Override
    public int insertAwardRecord(AwardRecord awardRecord) {
        return baseMapper.insert(awardRecord);
    }

    /**
     * 修改我的成就
     *
     * @param awardRecord 我的成就
     * @return 结果
     */
    @Override
    public int updateAwardRecord(AwardRecord awardRecord) {

        return baseMapper.updateById(awardRecord);
    }

    /**
     * 批量删除我的成就
     *
     * @param awardIds 需要删除的我的成就
     *                 主键
     * @return 结果
     */
    @Override
    public int deleteAwardRecordByAwardIds(Long[] awardIds) {
        return awardRecordMapper.deleteAwardRecordByAwardIds(awardIds);
    }

    /**
     * 删除我的成就信息
     *
     * @param awardId 我的成就主键
     * @return 结果
     */
    @Override
    public int deleteAwardRecordByAwardId(Long awardId) {
        return baseMapper.deleteById(awardId);
    }


    /**
     * 统计每个成就类型的数量
     *
     * @return
     */
    @Override
    public List<Map<String, Object>> selectAwardLevelCount() {
        return awardRecordMapper.selectAwardLevelCount();
    }

    /**
     * 统计每个用户的成就数
     *
     * @return
     */
    @Override
    public List<Map<String, Object>> selectCountGroupByUserId() {
        return awardRecordMapper.selectCountGroupByUserId();
    }
}
